import { addCollection } from '@iconify/vue'
import f7 from '@iconify/json/json/f7.json'
import ri from '@iconify/json/json/ri.json'
import bi from '@iconify/json/json/bi.json'
import antDesign from '@iconify/json/json/ant-design.json'
import vscodeIcons from '@iconify/json/json/vscode-icons.json'
import svgSpinners from '@iconify/json/json/svg-spinners.json'
import flag from '@iconify/json/json/flag.json'
import wi from '@iconify/json/json/wi.json'
import fa6Solid from '@iconify/json/json/fa6-solid.json'

const jsons = [
  f7,
  ri,
  bi,
  antDesign,
  vscodeIcons,
  svgSpinners,
  flag,
  wi,
  fa6Solid,
]

// 引入用于文档参考
jsons.forEach((json: any) => {
  addCollection(json)
})

// 复制文本用于注册
const iconStr = (icon: any) => `
  {
    name: "${icon.name}",
    config: {
      "body": ${JSON.stringify(icon.body)},
      "width": ${icon.width},
      "height": ${icon.height},
    }
  },`

export const jsonList: any = jsons.map((el: any) => {
  return {
    name: el.info.name,
    prefix: el.prefix,
    icons: Object.entries(el.icons).map((iconArr: [string, any]) => ({ 
      name: iconArr[0], 
      str: iconStr({ name: `${el.prefix}:${iconArr[0]}`, body: iconArr[1].body, width: iconArr[1].width || el.width, height: iconArr[1].height || el.height })
    }))
  }
})
